package com.kymatrix.kycarbon.xsmd.common.exception;

import cn.hutool.core.util.StrUtil;
import com.kymatrix.kycarbon.xsmd.common.base.ErrorCode;

/**
 * 业务异常
 */
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 445445701327085003L;
    private final Integer status;

    public BusinessException() {
        this(10000, "服务器内部错误");
    }

    public BusinessException(String message) {
        this(10001, message);
    }

    public BusinessException(ErrorCode errorCode, String ... msgs) {
        this(StrUtil.format(errorCode.getMsg(), msgs));
    }

    public BusinessException(int code, String message) {
        super(message);
        this.status = code;
    }

    public BusinessException(String message, int code) {
        super(message);
        this.status = code;
    }

    public int getStatus() {
        return this.status;
    }


}
